#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N 4

typedef struct chunk
{
    char*ch;
    struct chunk*next;
}chunk;
typedef struct
{
    chunk*head,*tail;
    int curlen;
}string;
typedef int status;

string*Readstring();

void Insert(string*s1,int pos,char*s2);

void Clear(string*s);

void Print(string*s);

int main()
{
    freopen("6-2.in","r",stdin);
    int T;
    scanf("%d",&T);
    while(T--)
    {
        string*s1=Readstring();
        int n;
        char temp[81];
        scanf("%d %s",&n,temp);
        Insert(s1,n,temp);
        Print(s1);
        Clear(s1);
    }
    return 0;
}
/* 请在这里填写答案 */
#undef N
#define N 100011
#define min(x,y) (((x)>(y))?(y):(x))

chunk*buildChunk(char s[],int*i)
{
    chunk*c=(chunk*)malloc(sizeof(chunk));
    c->next=NULL;
    c->ch=(char*)malloc((sizeof(char))*N);
    for(int j=0;s[*i]&&j<N;c->ch[j]=s[*i],++*i,++j);
    return c;
}

void Add(string*s1,char*s2,int slen)
{
    int len=0;
    if(s1->tail&&s1->curlen%N!=0)
    {
        len=N-s1->curlen%N;
        len=min(len,slen);
        memcpy(s1->tail->ch+s1->curlen%N,s2,len);
    }
    while(len<slen)
    {
        chunk*p=buildChunk(s2,&len);
        if(s1->tail==NULL)
            s1->head=p;
        else
            s1->tail->next=p;
        s1->tail=p;
    }
    s1->curlen+=slen;
}

string*Newstring()
{
    string*s=(string*)malloc(sizeof(string));
    s->curlen=0;
    s->head=NULL;
    s->tail=NULL;
    return s;
}

string*Readstring()
{
    string*s=Newstring();
    chunk*c=(chunk*)malloc(sizeof(chunk));
    c->next=NULL;
    c->ch=(char*)malloc((sizeof(char))*N);
    scanf("%s",c->ch);
    s->head=s->tail=c;
    s->curlen+=strlen(c->ch);
    return s;
}

void ClearWithoutS(string*s)
{
    for(chunk*p=s->head;p;)
    {
        chunk*tmp=p->next;
        free(p->ch);
        free(p);
        p=tmp;
    }
}

void Insert(string*s1,int pos,char*s2)
{
    int len=0;
    for(chunk *p=s1->head;p;p=p->next)
        for(int i=0;i<N&&len<s1->curlen;++i,++len)
        {
            if(len==pos)
                printf("%s",s2);
            putchar(p->ch[i]);
        }
    putchar('\n');
}

void Clear(string*s)
{
    ClearWithoutS(s);
    free(s);
}

void Print(string*s)
{
}


